import { post } from '@/utils/request'
import { convertBase64ToBlob, base64ToFile } from '@/utils/fileUtils'
export interface uploadResult {
  url: string
}
export const upload = (base64: string) => {
  let file: Blob = convertBase64ToBlob(base64);
  console.log(111111111, file);
  // let fileName=new Date().getTime()+".png";
  // let file: File = base64ToFile(base64,fileName);

  const formData = new FormData();
  formData.append('file', file);
  let config = {
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  }

  return post<FormData, uploadResult>("/api/upload/add", formData, config)

}
